package com.mjk.common.base.constns;

import java.util.regex.Pattern;

/**
 * bee常量
 * @author jafek
 *
 */
public class BeeCommonConstns {
	/**
	 * 扫描的基础包
	 */
	public static final String BASE_PACKAGE = "com.mjk";

	private BeeCommonConstns(){}
	/**
	 * 出入参转化键 存放于redis
	 */
	public static final String INOUT_PARAMS_MAPPING = "inoutmapping";
	/**
     * 删除标志 0 未删除
     */
    public static final String DEFAULT_UNDEL = "0";

    /**
     * 删除标志 1 删除
     */
	public static final String DEFAULT_DEL = "1";
    /**
	 * 有效标志
     */
    public static final String ACTIVE_STATUS = "1";
	/**
	 * 动态类属性开头
	 */
	public static final String CGLIB_FIX = "$cglib_prop_";
	/**
     * 反斜杠
     */
    public static final String BACKS_LASH = "/";
    //------------------------------正则-------------------------
    public static final String NUMBER_MATCH = "[^0-9]";
    /**
	 * 注释行正则
	 */
	public static final String NOTE_MATCH="<!--.*?-->";
	/**
	 * 解析分隔符，用于分隔多个解析语句 或者函数
	 * 
	 */
	public static final String PARSING_SPLIT = ";[\\r\\n]?";
	/**
	 * 每条SQL语句中如果存在变量开头的，则需要把查询结果保存到变量中
	 * "^#\\{(?:(?<key>[^,|^=]+))?(,?)(databaseId=[\"'](?<databaseId>[^\"]+)[\"'])?\\}="
	 */
	public static final String SET_PARAMS_MATH= "^#\\{(?:(?<key>[^,|^=]+))?(,?)(databaseId=[\"'](?<databaseId>[^,|^=]+)[\"'])?\\}=";
	
	/**
	 * template 中的变量获取
	 */
	public static final String TEMPLATE_PARAMS_MATH="#\\{([^}]+)\\}";
	/**
	 * 变量数组设置
	 */
	public static final String SET_PARAMS_LIST_MATCH = "\\[(.*?)\\]";
	
	/**
	 * 接收变量中是否存在分隔符
	 */
	public static final String PARAMS_SPLIT = "\\.";
	/**
	 * http模板 变量匹配
	 */
	public static final String HTTP_PARAMS_TEMPLATE_MATH="#\\{([^}]+)\\}";
	/**
	 * 参数如果需要返回obj的需要一obj结尾
	 */
	public static final String SET_PARAMS_OBJ = "(?i).*obj$";
	/**
	 * 参数如果需要返回数组的需要以list结尾
	 */
	public static final String SET_PARAMS_LIST = "(?i).*list$";
	/**
	 * SQL语句匹配
	 */
	public static final String SQL_MATCH = "^(?i)(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER).*";
	/**
	 * if 正则表达式
	 */
	public static final String IF_MATCH = "<if\\s*test=[\"](.*?)[']\\s*>(.*?)</if>";
	/**
	 * forEach 正则表达式
	 */
	public static final String FOREACH_MATCH= "<foreach(?=\\s)(?=(?:[^>=]|=(?!\\s))*\\scollection=(['\"])(?<collection>[^'']+)(['']))?" +
            "(?=(?:[^>=]|=(?!\\s))*\\sitem=([''])(?<item>[^'']+)(['']))?" +
            "(?=(?:[^>=]|=(?!\\s))*\\sindex=([''])(?<index>[^'']+)(['']))?" +
            "(?=(?:[^>=]|=(?!\\s))*\\sopen=([''])(?<open>[^'']+)(['']))?" +
            "(?=(?:[^>=]|=(?!\\s))*\\sclose=([''])(?<close>[^'']+)(['']))?" +
            "(?=(?:[^>=]|=(?!\\s))*\\sseparator=([''])(?<separator>[^'']*)(['']))?" +
            "[^>]*>(?<content>[^<]*)</foreach>";
	/**
	 * choose 获取正则
	 */
	public static final String CHOOSEREGEX = "<choose>(.*?)</choose>";
	/**
	 * choose中when 获取正则  test=\"([^\"]*)\"
	 */
	public static final String WHENREGEX = "<when(?=\\s)(?=(?:[^>=]|=(?!\\s))*\\stest=([''](?<test>[^']+)[']))?[^>]*>(?<content>[^<]*)<\\/when>";
	/**
	 * choose中 otherwiseregex 获取
	 */
	public static final String OTHERWISEREGEX = "<otherwise>(?<content>[^<]*)<\\/otherwise>";
	/**
	 * Corn表达式正则
	 */
	public static final String CORN_MATCH = "^(\\*(\\/\\d+)?|\\d+((-\\d+)?(,\\d+)*)(\\/\\d+)?|\\?|\\*|\\*\\s\\?\\s\\*\\s\\*|\\d+\\s\\*\\s\\?\\s\\*\\s\\*)\\s(\\*(\\/\\d+)?|\\d+((-\\d+)?(,\\d+)*)(\\/\\d+)?|\\?|\\*|[a-zA-Z]{3}([a-zA-Z]{3})?|\\d+[a-zA-Z]{3}|\\d+\\s[a-zA-Z]{3}([a-zA-Z]{3})?)\\s(\\*(\\/\\d+)?|\\d+((-\\d+)?(,\\d+)*)(\\/\\d+)?|\\?|\\*|[a-zA-Z]{3}([a-zA-Z]{3})?|\\d+[a-zA-Z]{3}|\\d+\\s[a-zA-Z]{3}([a-zA-Z]{3})?)\\s(\\*(\\/\\d+)?|\\d+((-\\d+)?(,\\d+)*)(\\/\\d+)?|\\?|\\*|[a-zA-Z]{3}([a-zA-Z]{3})?|\\d+[a-zA-Z]{3}|\\d+\\s[a-zA-Z]{3}([a-zA-Z]{3})?)\\s(\\*(\\/\\d+)?|\\d+((-\\d+)?(,\\d+)*)(\\/\\d+)?|\\?|\\*|[a-zA-Z]{3}([a-zA-Z]{3})?|\\d+[a-zA-Z]{3}|\\d+\\s[a-zA-Z]{3}([a-zA-Z]{3})?)\\s(\\*(\\/\\d+)?|\\d+((-\\d+)?(,\\d+)*)(\\/\\d+)?|\\?|\\*|[a-zA-Z]{3}([a-zA-Z]{3})?|\\d+[a-zA-Z]{3}|\\d+\\s[a-zA-Z]{3}([a-zA-Z]{3})?)$";
	/**
	 * http正则表达式
	 */
	public static final String HTTP_MATCH = "^((http|https):\\/\\/)?([a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}|localhost)(:[0-9]{1,5})?(\\/.*)?$";

	//------------------------jdbc constns----------------
	/**
	 * 用于update的时候 空字段设值
	 */
	public static final String JDBC_NULL = "JDBCNULL";

	public static final Short JDBC_SHORT_NULL =0;

	public static final String JDBC_SPACE = "JDBCSPACE";
	/**
	 * 函数试入口
	 */
	public static final String JDBC_SPECIAL_CHAR = "<![CDATA[%s]]>";
	/**
	 * 函数式 正则
	 */
	public static final Pattern JDBC_SPECIAL_CHAR_PATTERN = Pattern.compile("<!\\[CDATA\\[(.*)\\]\\]>");
}
